
*********************************************************************************************************************
/****** YRBS *******
clear
set more off, perm
set varabbrev off
*********************************************************************************
use "national_yrbs_19912013.dta", clear
gen nat_indicator=1
append using "state_yrbs_19912013.dta"
replace nat_indicator=0 if missing(nat_indicator)

keep if inrange(year,1991,2013)
keep fips year age year race race_new raceeth_new sex grade_new grade nat_indicator natweight alch_days alch_binge drive_drunk drive_drunk1


*age
replace age = 12 if age == 1
replace age = 13 if age == 2
replace age = 14 if age == 3
replace age = 15 if age == 4
replace age = 16 if age == 5
replace age = 17 if age == 6
replace age = 18 if age == 7
replace age = 18 if age == 8 | age==19

gen age_sq=age*age

*grade
replace grade = 9 if grade == 1
replace grade = 10 if grade == 2
replace grade = 11 if grade == 3
replace grade = 12 if grade == 4
replace grade = 0 if grade == 5

replace grade = 8 if grade_new == 1
replace grade = 9 if grade_new == 2
replace grade = 10 if grade_new == 3
replace grade = 11 if grade_new == 4
replace grade = 12 if grade_new == 5
replace grade = 0 if grade_new == 6

*sex=1 if female
gen male = 0 if sex==1
replace male = 1 if sex==2

*race
/*race: How do you describe yourself?
1.	Am Indian/Alaska Native
2.	Asian
3.	Black or African American
4.	Hispanic or Latino
5.	Native Hawaiian or Other Pacific Islander
6.	White
7.	Multiple ֠Hispanic
8.	Multiple - Non-hispanic*/
*black
gen black = 1 if race == 3 
replace black = 0 if inlist(race,1,2,4,5,6,7,8)

*white
gen white = 1 if race == 6
replace white = 0 if  inlist(race,1,2,3,4,5,7,8)

*hispanic
gen hispanic = 1 if race==4
replace hispanic = 0 if  inlist(race,1,2,3,5,6,7,8)

*other
gen other_race = 1 if inlist(race,1,7,8) | inlist(race,2,5)
replace other_race = 0 if inlist(race,3,4,6)



/*race_new" What is your race?
1.	Am Indian/Alaska Native
2.	Asian
3.	Black or African American
4.	Native Hawaiian/other PI
5.	White
6.	Hispanic/Latino
7.	Multiple ֠Hispanic
8.	Multiple - non-Hispanic*/

replace black = 1 if race_new == 3 
replace black = 0 if inlist(race_new,1,2,4,5,6,7,8)

*white
replace white = 1 if race_new == 5
replace white = 0 if inlist(race_new,1,2,3,4,6,7,8)

*hispanic
replace hispanic = 1 if race_new==6
replace hispanic = 0 if inlist(race_new,1,2,3,4,5,7,8)

*other 
replace other_race = 1 if inlist(race_new,1,7,8) | inlist(race_new,2,4)
replace other_race = 0 if inlist(race_new,3,5,6)


/*raceeth_new: How do you describe yourself?
1.	White-not Hispanic
2.	Black-not Hispanic
3.	Hispanic
4.	Asian or Pacific Islander
5.	Native American or Alaskan Native
6.	Other
*/

replace black = 1 if raceeth_new == 2
replace black = 0 if inlist(raceeth_new,1,3,4,5,6)

*white
replace white = 1 if raceeth_new == 1
replace white = 0 if inlist(raceeth_new,2,3,4,5,6)

*hispanic
replace hispanic = 1 if raceeth_new==3
replace hispanic = 0 if inlist(raceeth_new,1,2,4,5,6)

*other
replace other_race = 1 if inlist(raceeth_new,5,6) | raceeth_new==4
replace other_race = 0 if inlist(raceeth_new,1,2,3)


tab alch_days
tab alch_binge
tab drive_drunk

/*During the past 30 days, on how many days have you had at least one drink of alcohol?
1.	0 days
2.	1 to 2
3.	3 to 5
4.	6 to 9
5.	10 to 19
6.	20 to 29
7.	All 30*/

gen alcohol_days=0 if alch_days==1
replace alcohol_days=1.5 if alch_days==2
replace alcohol_days=4 if alch_days==3
replace alcohol_days=7.5 if alch_days==4
replace alcohol_days=14.5 if alch_days==5
replace alcohol_days=24.5 if alch_days==6
replace alcohol_days=30 if alch_days==7

gen anyalcohol=1 if alch_days==2|alch_days==3|alch_days==4|alch_days==5|alch_days==6|alch_days==7
replace anyalcohol=0 if alch_days==1
tab anyalcohol

gen bingedrinks=1 if alch_binge==2|alch_binge==3|alch_binge==4|alch_binge==5|alch_binge==6|alch_binge==7
replace bingedrinks=0 if alch_binge==1
tab bingedrinks

gen freqbinge=1 if alch_binge==4|alch_binge==5|alch_binge==6|alch_binge==7
replace freqbinge=0 if alch_binge==1|alch_binge==2|alch_binge==3
tab freqbinge
tab drive_drunk

/*During the last 30 days, how many days did you have 5 or more drinks of alcohol in a row within a few hours?
1.	0 days
2.	1
3.	2
4.	3 to 5
5.	6 to 9
6.	10 to 19
7.	20 or more
*/
gen bingedrinks_days=0 if alch_binge==1
replace bingedrinks_days=1 if alch_binge==2
replace bingedrinks_days=2 if alch_binge==3
replace bingedrinks_days=4 if alch_binge==4
replace bingedrinks_days=7.5 if alch_binge==5
replace bingedrinks_days=14.5 if alch_binge==6
replace bingedrinks_days=20 if alch_binge==7


gen drunkdrive=1 if drive_drunk==2|drive_drunk==3|drive_drunk==4|drive_drunk==5
replace drunkdrive=0 if drive_drunk==1
replace drunkdrive=1 if inrange(drive_drunk1,3,6)
replace drunkdrive=0 if inrange(drive_drunk1,1,2)
tab drunkdrive

/*drive_drunk
During the past 30 days, how many times did you drive a car or other vehicle when you had been drinking alcohol?
1.	0 times
2.	1 time
3.	2 or 3 times
4.	4 or 5 times
5.	6 or more times
*/

gen drunkdrive_fre=0 if drive_drunk==1
replace drunkdrive_fre=1 if drive_drunk==2
replace drunkdrive_fre=2.5 if drive_drunk==3
replace drunkdrive_fre=4.5 if drive_drunk==4
replace drunkdrive_fre=6 if drive_drunk==5

/*drive_drunk1
During the past 30 days, how many times did you drive a car or other vehicle when you had been drinking alcohol?
1.	I didnӴ drive a car during the past 30 days
2.	0 times
3.	1 time
4.	2 or 3
5.	4 or 5
6.	6 or more times*/

replace drunkdrive_fre=0 if drive_drunk1==1|drive_drunk1==2
replace drunkdrive_fre=1 if drive_drunk1==3
replace drunkdrive_fre=2.5 if drive_drunk1==4
replace drunkdrive_fre=4.5 if drive_drunk1==5
replace drunkdrive_fre=6 if drive_drunk1==6

gen drunkdrive_fre_cond=drunkdrive_fre if inrange(drunkdrive_fre,1,6)

generate trend=.
replace trend=1 if year==1991
replace trend=2 if year==1992
replace trend=3 if year==1993
replace trend=4 if year==1994
replace trend=5 if year==1995
replace trend=6 if year==1996
replace trend=7 if year==1997
replace trend=8 if year==1998
replace trend=9 if year==1999
replace trend=10 if year==2000
replace trend=11 if year==2001
replace trend=12 if year==2002
replace trend=13 if year==2003
replace trend=14 if year==2004
replace trend=15 if year==2005
replace trend=16 if year==2006
replace trend=17 if year==2007
replace trend=18 if year==2008
replace trend=19 if year==2009
replace trend=20 if year==2010
replace trend=21 if year==2011
replace trend=22 if year==2012
replace trend=23 if year==2013

*merge in weight variable
gen racew=white
replace racew=2 if black==1
replace racew=3 if other_race==1|hispanic==1
count
tab age
gen state=fips
merge m:1 state racew male age year using "state_pop_weight.dta", keepus(state_pops)
drop if _merge==2
drop _merge 

*merge in control variables
merge m:1 state year using "controls19912013.dta"
drop _merge

merge m:1 year state using "fars.dta", keepus(nonDUI_1620)
ge lnorate1620 = ln(nonDUI_1620/pop1620)
replace lnorate1620 = ln(0.1/pop1620) if nonDUI_1620==0
drop if _merge==2
drop _merge

*keep respondents ages 16 and up
keep if inrange(age,16,18)


save "mw-drinking-yrbs", replace
*/
*********************************************************************************************************************
